﻿using MediatR;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MediatR_.MediatR_RequestStream
{
    public class CounterStreamRequestHandle  //: IStreamRequestHandler<CounterStreamRequest, int>
    {
        public async IAsyncEnumerable<int> Handle(CounterStreamRequest request, CancellationToken cancellationToken)
        {
            //throw new NotImplementedException();
            int count = 0;
            while (!cancellationToken.IsCancellationRequested)
            {
                await Task.Delay(500, cancellationToken);
                yield return count;
                count++;
            }
        }
    }
}
